]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
gestures: Restrict actions based on keybindingMode
authorFlorian Müllner <fmuellner@gnome.org>
Thu, 27 Nov 2014 19:46:50 +0000 (20:46 +0100)
committerFlorian Müllner <fmuellner@gnome.org>
Fri, 19 Dec 2014 10:39:50 +0000 (11:39 +0100)
Just like keybindings and the message tray pointer barrier, gestures
don't always make sense - for instance, swiping up the screen shield
should not trigger the message tray just as the SelectArea action around
the left edge should not open the overview.
To avoid this, restrict gestures based on the current keybinding mode.

https://bugzilla.gnome.org/show_bug.cgi?id=740237

js/ui/edgeDragAction.js
js/ui/messageTray.js
js/ui/viewSelector.js
js/ui/windowManager.js

index 692da414691208be9991f1774a24fdf104ad6556..46e96d7a9b0f305663553ec8b10a8c39147f9331 100644 (file)
@@ -6,6 +6,8 @@ const Meta = imports.gi.Meta;
 const Clutter = imports.gi.Clutter;
 const St = imports.gi.St;
 
+const Main = imports.ui.main;
+
 const EDGE_THRESHOLD = 20;
 const DRAG_DISTANCE = 80;
 
@@ -13,9 +15,10 @@ const EdgeDragAction = new Lang.Class({
     Name: 'EdgeDragAction',
     Extends: Clutter.GestureAction,
 
-    _init : function(side) {
+    _init : function(side, allowedModes) {
         this.parent();
         this._side = side;
+        this._allowedModes = allowedModes;
         this.set_n_touch_points(1);
 
         global.display.connect('grab-op-begin', Lang.bind(this, function() {
@@ -34,6 +37,9 @@ const EdgeDragAction = new Lang.Class({
         if (this.get_n_current_points() == 0)
             return false;
 
+        if (!(this._allowedModes & Main.keybindingMode))
+            return false;
+
         let [x, y] = this.get_press_coords(0);
         let monitorRect = this._getMonitorRect(x, y);
 
index ad7c5c8869d6b373a24c4c03c0619f32caeade4d..a034fc399250edbd4ec8235a7ce1a78d41962b95 100644 (file)
@@ -1951,7 +1951,9 @@ const MessageTray = new Lang.Class({
         this._messageTrayMenuButton.actor.connect('key-press-event',
                                                   Lang.bind(this, this._onTrayButtonKeyPress));
 
-        let gesture = new EdgeDragAction.EdgeDragAction(St.Side.BOTTOM);
+        let gesture = new EdgeDragAction.EdgeDragAction(St.Side.BOTTOM,
+                                                        Shell.KeyBindingMode.NORMAL |
+                                                        Shell.KeyBindingMode.OVERVIEW);
         gesture.connect('activated', Lang.bind(this, this.toggle));
         global.stage.add_action(gesture);
     },
index d0e8140967ca0e8a1ad1c482f4ba670233faf5af..57395e38c6bae7fe9c7e9114d0fbc6651fb4efb9 100644 (file)
@@ -65,7 +65,8 @@ const ShowOverviewAction = new Lang.Class({
     },
 
     vfunc_gesture_prepare : function(action, actor) {
-        return this.get_n_current_points() == this.get_n_touch_points();
+        return Main.keybindingMode == Shell.KeyBindingMode.NORMAL &&
+               this.get_n_current_points() == this.get_n_touch_points();
     },
 
     _getBoundingRect : function(motion) {
@@ -215,7 +216,8 @@ const ViewSelector = new Lang.Class({
 
         let gesture;
 
-        gesture = new EdgeDragAction.EdgeDragAction(St.Side.LEFT);
+        gesture = new EdgeDragAction.EdgeDragAction(St.Side.LEFT,
+                                                    Shell.KeyBindingMode.NORMAL);
         gesture.connect('activated', Lang.bind(this, function() {
             if (Main.overview.visible)
                 Main.overview.hide();
index 60ab30f7a30d42b9328871347303e872c53342e0..e3325527e45628c29b64bfd16a465f2d8d18c9c4 100644 (file)
@@ -478,7 +478,9 @@ const WorkspaceSwitchAction = new Lang.Class({
     },
 
     vfunc_gesture_prepare : function(action, actor) {
-        return this.get_n_current_points() == this.get_n_touch_points();
+        let allowedModes = Shell.KeyBindingMode.NORMAL | Shell.KeyBindingMode.OVERVIEW;
+        return this.get_n_current_points() == this.get_n_touch_points() &&
+               (allowedModes & Main.keybindingMode);
     },
 
     vfunc_gesture_end : function(action, actor) {
@@ -526,7 +528,7 @@ const AppSwitchAction = new Lang.Class({
     },
 
     vfunc_gesture_prepare : function(action, actor) {
-        if (Main.overview.visible) {
+        if (Main.keybindingMode != Shell.KeyBindingMode.NORMAL) {
             this.cancel();
             return false;
         }